package com.ricky;

import com.ricky.service2.RickyConfig01;
import com.ricky.service2.RickyService2;
import com.ricky02.Ricky02Service;
import com.ricky02.RickyConfig02;
import com.ricky03.Ricky03Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * SpringBoot运行原理分析
 *
 * 注意  此种方式 默认需要内置tomcat或者内置jetty支持
 */
//开启SpringBoot自动注入配置  等价于原来的SpringBootApplication
//@EnableAutoConfiguration
//@SpringBootApplication(scanBasePackages = {"com.ricky","com.ricky02"})
//@SpringBootApplication(scanBasePackages = {"com.ricky","com.ricky02"},exclude = HibernateJpaAutoConfiguration.class)
//@SpringBootApplication(scanBasePackages = {"com.ricky","com.ricky02"},excludeName = "org.springframework.boot.autoconfigure.orm.jpaHibernateJpaAutoConfiguration.class")
//@SpringBootApplication(scanBasePackages = {"com.ricky","com.ricky02"},scanBasePackageClasses = Ricky03Config.class)
//开启RestController注解  含有ResponseBody 即非页面形式
@RestController
public class SpringBootApplication06_2 {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @GetMapping("/")
    public String home(HttpServletRequest request) {
        logger.info("HelloWorld 访问成功");
        return "Hello World!";
    }

    /**
     * 开启SpringBoot服务
     * @param args
     */
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringBootApplication06_2.class, args);

        String[] names = context.getBeanDefinitionNames();
        for (String name:names){
            System.out.println(name);
        }

        context.close();
    }
}